﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:model="clr-namespace:ReporterEngine;assembly=ReporterEngine"
             xmlns:converters="clr-namespace:ReporterControlLibrary.Converters" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" x:Class="ReporterControlLibrary.TemplateTree"
             mc:Ignorable="d" 
             d:DesignHeight="300" 
             d:DesignWidth="300"
             x:Name="thisUC">

    <Grid>
        <TreeView x:Name="modelTree" Background="{Binding ElementName=thisUC, Path=TreeBackground}" SelectedItemChanged="ModelTreeSelectedItemChanged" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" DataContext="{Binding TemplateTreeSource}" ItemsSource="{Binding Root.Childs}" Style="{DynamicResource ModelTreeViewStyle}" ItemContainerStyle="{DynamicResource ModelTreeViewItemContainerStyle}" >

            <TreeView.Resources>

               <HierarchicalDataTemplate 
    				DataType="{x:Type model:TemplateNode}" 
    				ItemsSource="{Binding Childs}">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Command.CommandName}" Margin="0,0,5,0" Foreground="{DynamicResource CommandNameColor}" Style="{DynamicResource FormLabelStyle}"/>
                        <TextBlock x:Name="textBlock" Text="{Binding CommandType}" Margin="0,0,5,0" Foreground="{DynamicResource CommandTypeColor}" Style="{DynamicResource FormLabelStyle}"/>
                        <TextBlock Text="{Binding Command.Query}" Foreground="{DynamicResource QueryColor}" Style="{DynamicResource FormLabelStyle}"/>
                    </StackPanel>
                </HierarchicalDataTemplate>

            </TreeView.Resources>            
            <!--<i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectedItemChanged">
                    <i:InvokeCommandAction Command="{Binding ModelTreeSelectedItemChangedCommand, Mode=OneWay, Source={StaticResource ApplicationManager}}" CommandParameter="{Binding Mode=OneWay}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>-->
        </TreeView>
    </Grid>
</UserControl>
